package com.ruoyi.web.controller.wq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.websocket.annotation.Online;
import com.ruoyi.framework.web.service.FriendApplyService;
import com.ruoyi.wq.domain.WqFriendApply;
import com.ruoyi.wq.domain.vo.WqFriendApplyVO;
import com.ruoyi.wq.service.IWqFriendApplyService;

/**
 * 好友申请Controller
 * 
 * @author ruoyi
 * @date 2022-08-02
 */
@RestController
@RequestMapping("/wq/friendApply")
public class WqFriendApplyController extends BaseController{
	
    @Autowired
    private IWqFriendApplyService wqFriendApplyService;
    
    @Autowired
    private FriendApplyService friendApplyService;
    
    /**
     * 查询好友申请列表
     */
    @GetMapping("/myList")
    public TableDataInfo myList(WqFriendApply wqFriendApply){
    	TableDataInfo list = wqFriendApplyService.getMyList(wqFriendApply);
        return list;
    }
    
    /**
     * 查询好友申请列表
     */
    @GetMapping("/myApply")
    public TableDataInfo myApply(WqFriendApply wqFriendApply){
    	TableDataInfo list = wqFriendApplyService.getMyApply(wqFriendApply);
        return list;
    }

    /**
     * 获取好友申请详细信息
     */
    @GetMapping("/getDetail")
    public AjaxResult getDetail(String id) {
        return AjaxResult.success(wqFriendApplyService.getDetail(id));
    }
    
    /**
     * 获取未读好友申请
     */
    @GetMapping("/getUnRead")
    public AjaxResult getUnRead() {
        return AjaxResult.success(wqFriendApplyService.getUnRead());
    }
    
    /**
     * 获取好友申请详细信息
     */
    @GetMapping("/getRoom")
    public AjaxResult getRoom(String id) {
        return AjaxResult.success(wqFriendApplyService.getRoom(id));
    }

    /**
     * 新增好友申请
     */
    @Online
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WqFriendApply wqFriendApply){
    	/*if(1152 == SecurityUtils.getUserId().intValue()){
    		friendApplyService.sendMsg(wqFriendApply.getUserId());
    		return AjaxResult.success();
    	}*/
        return AjaxResult.success(friendApplyService.addFriendApply(wqFriendApply));
    }
    
    /**
     * 新增好友申请
     */
    @RepeatSubmit
    @PostMapping("/addChat")
    public AjaxResult addChat(@RequestBody WqFriendApply wqFriendApply){
        return AjaxResult.success(friendApplyService.addChat(wqFriendApply));
    }
    
    /**
     * 添加微信
     */
    @Online
    @PostMapping("/addWechat")
    public AjaxResult addWechat(@RequestBody WqFriendApply wqFriendApply){
    	/*if(1152 == SecurityUtils.getUserId().intValue()){
    		friendApplyService.sendMsg(wqFriendApply.getUserId());
    		return AjaxResult.success();
    	}*/
        return AjaxResult.success(friendApplyService.addWechat(wqFriendApply));
    }
    
    /**
     * 添加微信
     */
    @Online
    @PostMapping("/getWechat")
    public AjaxResult getWechat(@RequestBody WqFriendApplyVO wqFriendApply){
        return AjaxResult.success(friendApplyService.getWechat(wqFriendApply));
    }
    
    /**
     * 添加微信
     */
    @Online
    @PostMapping("/addVipWechat")
    public AjaxResult addVipWechat(@RequestBody WqFriendApply wqFriendApply){
        return friendApplyService.addVipWechat(wqFriendApply);
    }
    
    /**
     * 添加微信
     */
    @Online
    @GetMapping("/getLuck")
    public AjaxResult getLuck(){
        return AjaxResult.success(friendApplyService.getLuck());
    }
    
    /**
     * 升级关系
     */
    @PostMapping("/addHot")
    public AjaxResult addHot(@RequestBody WqFriendApply wqFriendApply){
        return AjaxResult.success(friendApplyService.updateFriendApplyHot(wqFriendApply));
    }
    
    /**
     * 拒绝好友申请
     */
    @PostMapping("/jujue")
    public AjaxResult jujue(@RequestBody WqFriendApply wqFriendApply){
    	friendApplyService.updateJujue(wqFriendApply);
        return AjaxResult.success();
    }
    
    /**
     * 同意好友申请
     */
    @PostMapping("/agree")
    public AjaxResult agree(@RequestBody WqFriendApply wqFriendApply){
    	friendApplyService.updateAgree(wqFriendApply);
        return AjaxResult.success();
    }

}
